﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TaiwuModFramework.Common.Abstract;
using TaiwuModFramework.Common.Attribute;
using TaiwuModFramework.Common.Base;

namespace TaiwuModFramework.Backend.Comp {
    public class LogLevelComp : BaseTaiwuComp {

        private  ALogger Log;

        [AttrConfigItem("loggerLevel")]
        public int level {
            get { return Log==null?Int32.MaxValue : (int)Log.Level; }
            set {
                var level = ALogger.LevelParse(value);
                if(level != Log.Level) {
                    var s = $"日志等级 {Log.Level} --> {level}";
                    Log.Level = ALogger.LEVEL.INFO;
                    Log.Info(s);
                    Log.Level = level ;
                }
                
                ;
            }
        }
    }
}
